import { IsNotEmpty, IsNumber, IsString, Matches } from 'class-validator';
import { TimeSlot } from '../../time-slots/entities/time-slot.entity';
import { ApiProperty } from '@nestjs/swagger';

export class UpdateLessonsSortDto {
  @ApiProperty({
    example: '2022-02-02',
    description: '年月日必须填写',
    required: true,
  })
  @Matches(/^\d{4}-\d{2}-\d{2}$/, {
    message: 'Invalid format. Expected format:  YYYY-MM-DD',
  })
  @IsNotEmpty({ groups: ['create'], message: '年月日必须填写' })
  start_date: string;

  @ApiProperty({
    example: '2022-02-02',
    description: '年月日必须填写',
    required: true,
  })
  @Matches(/^\d{4}-\d{2}-\d{2}$/, {
    message: 'Invalid format. Expected format:  YYYY-MM-DD',
  })
  @IsNotEmpty({ groups: ['create'], message: '年月日必须填写' })
  end_date: string;

  @ApiProperty({ example: '周一', description: '星期', required: true })
  @IsString()
  @IsNotEmpty({
    groups: ['create'],
    message: '周，周一，周二，周三，周四，周五，周六，周七',
  })
  week: string;

  @ApiProperty({ example: '1', description: '节数', required: true })
  @IsNumber()
  @IsNotEmpty({ groups: ['create'], message: '节数' })
  several: number;

  @ApiProperty({ example: '1', description: '教室id', required: true })
  @IsNumber()
  @IsNotEmpty({ groups: ['create'], message: '教室id' })
  class_room_id: number;

  @ApiProperty({ example: '1', description: '课程id', required: true })
  @IsNumber()
  @IsNotEmpty({ groups: ['create'], message: '课程id' })
  course_id: number;

  @ApiProperty({ example: 1, description: '教师id', required: true })
  @IsNumber()
  @IsNotEmpty({ groups: ['create'], message: '教师id' })
  teacher_id: number;

  @ApiProperty({
    example: [1, 2, 3],
    description: '时间段',
    isArray: true,
    required: true,
  })
  @IsNumber(
    {
      allowNaN: false,
      allowInfinity: false,
    },
    { each: true },
  )
  @IsNotEmpty({ groups: ['create'], message: '请选择时间段' })
  timeSlotsId: number[];

  timeSlots: TimeSlot[];
}
